home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / Emulation_Include_Files / recog.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  9.3 KB  |  237 lines

  1. /***************************************************************************\
  2. *
  3. * RECOG.H - Handwriting functions, types, and definitions
  4. *
  5. *    Version 1.1
  6. *
  7. *    Copyright (c) 1992-1998 Microsoft Corp. All rights reserved.
  8. *
  9. \***************************************************************************/
  10.  
  11. #ifndef _INC_RECOG
  12. #define _INC_RECOG
  13.  
  14. #include <windows.h>
  15.  
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif /* __cplusplus */
  19.  
  20. /* Suggested sequence for using these APIs:
  21.  *
  22.  *    HwxConfig (once only)
  23.  *        HwxCreate (once per recognition panel)
  24.  *        HwxSetGuide
  25.  *        HwxSetAlphabet
  26.  *        HwxSetContext    (if there is a previous character)
  27.  *            HwxInput    (as the user writes)
  28.  *            HwxProcess  (to process the ink input)
  29.  *            HwxResultsAvailable (find out if new results are available)
  30.  *                HwxGetResults   (every time there are any results available)
  31.  *        HwxEndInput (when user is done inputting ink)
  32.  *        HwxProcess  (to process the ink input)
  33.  *        HwxGetResults (to get the last characters)
  34.  *        HwxDestroy
  35.  */
  36.  
  37. // The constants below are used with HWXSetAlphabet().  These specify which
  38. // character groupings to recognize.
  39. #define ALC_WHITE            0x00000001    // White space.
  40. #define ALC_LCALPHA            0x00000002    // a..z
  41. #define ALC_UCALPHA            0x00000004    // A..Z
  42. #define ALC_NUMERIC            0x00000008    // 0..9
  43. #define ALC_PUNC            0x00000010    // Standard punc., language dependent.
  44. #define    ALC_NUMERIC_PUNC    0x00000020    // Non digit characters in numbers.
  45. #define ALC_MATH            0x00000040    // %^*()-+={}<>,/.  (??? language dependent ???)
  46. #define ALC_MONETARY        0x00000080    // Punct. in local monetary expressions.
  47. #define    ALC_COMMON_SYMBOLS    0x00000100    // Commonly used symbols from all categories.
  48. #define ALC_OTHER            0x00000200    // Other punctuation not typically used.
  49. #define ALC_ASCII            0x00000400    // 7-bit chars 20..7F
  50. #define ALC_HIRAGANA        0x00000800    // Hiragana (JPN)
  51. #define ALC_KATAKANA        0x00001000    // Katakana (JPN)
  52. #define ALC_KANJI_COMMON    0x00002000    // Common Kanji (JPN)
  53. #define ALC_KANJI_RARE        0x00004000    // Common Kanji (JPN)
  54. #define    ALC_HANGUL_COMMON    0x00008000    // Common Hangul used in Korea.
  55. #define    ALC_HANGUL_RARE        0x00010000    // The rest of the Hangul used in Korea.
  56. #define ALC_UNUSED            0x00FE0000    // Reserved for future use.
  57. #define ALC_OEM                0xFF000000    // OEM recognizer-specific.
  58.  
  59. // Useful groupings
  60.  
  61. #define ALC_ALPHA            (ALC_LCALPHA | ALC_UCALPHA)
  62. #define ALC_ALPHANUMERIC    (ALC_ALPHA | ALC_NUMERIC)
  63. #define    ALC_KANA            (ALC_HIRAGANA | ALC_KATAKANA)
  64. #define    ALC_KANJI_ALL        (ALC_KANJI_COMMON | ALC_KANJI_RARE)
  65. #define    ALC_HANGUL_ALL        (ALC_HANGUL_COMMON | ALC_HANGUL_RARE)
  66. #define    ALC_EXTENDED_SYM    (ALC_MATH | ALC_MONETARY | ALC_OTHER)
  67. #define ALC_SYS_MINIMUM        (ALC_ALPHANUMERIC | ALC_PUNC | ALC_WHITE)
  68. #define ALC_SYS_DEFAULT        (ALC_SYS_MINIMUM | ALC_COMMON_SYMBOLS)
  69.  
  70. // Standard configurations for various languages.
  71.  
  72. #define    ALC_USA_COMMON        (ALC_SYS_DEFAULT)
  73. #define    ALC_USA_EXTENDED    (ALC_USA_COMMON | ALC_EXTENDED_SYM)
  74.  
  75. #define    ALC_JPN_COMMON        (ALC_SYS_DEFAULT | ALC_KANA | ALC_KANJI_COMMON)
  76. #define    ALC_JPN_EXTENDED    (ALC_JPN_COMMON | ALC_EXTENDED_SYM | ALC_KANJI_RARE)
  77.  
  78. #define    ALC_CHS_COMMON        (ALC_SYS_DEFAULT | ALC_KANJI_COMMON)
  79. #define    ALC_CHS_EXTENDED    (ALC_CHS_COMMON | ALC_EXTENDED_SYM | ALC_KANJI_RARE)
  80.  
  81. #define    ALC_CHT_COMMON        (ALC_SYS_DEFAULT | ALC_KANJI_COMMON)
  82. #define    ALC_CHT_EXTENDED    (ALC_CHT_COMMON | ALC_EXTENDED_SYM | ALC_KANJI_RARE)
  83.  
  84. #define    ALC_KOR_COMMON        (ALC_SYS_DEFAULT | ALC_HANGUL_COMMON | ALC_KANJI_COMMON)
  85. #define    ALC_KOR_EXTENDED    (ALC_KOR_COMMON | ALC_EXTENDED_SYM | ALC_HANGUL_RARE | ALC_KANJI_RARE)
  86.  
  87. // Define ALC mask type.
  88. typedef LONG                ALC;        // Enabled Alphabet
  89. typedef ALC                    *PALC;        // ptr to ALC
  90.  
  91. // Handwriting Recognizer:
  92. DECLARE_HANDLE(HRC);            // Handwriting Recognition Context
  93.  
  94. typedef HRC            *PHRC;
  95.  
  96. // Filled in by HwxGetResults().
  97. // The rgChar array is actually a variable sized array of alternate results.  The number of
  98. // alternates is passed into HwxGetResults().
  99. typedef struct tagHWXRESULTS {
  100.     USHORT    indxBox;        // zero-based index into guide structure where char was written
  101.     WCHAR    rgChar[1];        // variable-sized array of characters returned
  102. } HWXRESULTS, *PHWXRESULTS;
  103.  
  104. // Passed in to HwxSetGuide().  Specifies where the boxes are on the screen.
  105. // All positions are in scaled screen coordinates.  You should do the scaling so
  106. // that cyWriting is around 1000.  To avoid speed and rounding problems you should
  107. // use an integral multiple of your actual size.
  108. // JRB: FIXME: Check description above is correct!!!
  109. // NOTE: the current code requires that the writing area be centered.  E.g. You
  110. // need to set cxBox, cxOffset and cxWriting such that:
  111. //        cxBox == 2 * cxOffset + cxWriting
  112. typedef struct tagHWXGUIDE {
  113.     // Number of input boxes in each direction.
  114.     UINT    cHorzBox;
  115.     UINT    cVertBox;
  116.  
  117.     // Upper left corner of input area.
  118.     INT        xOrigin;
  119.     INT        yOrigin;
  120.  
  121.     // Width and height of a single box.
  122.     UINT    cxBox;
  123.     UINT    cyBox;
  124.  
  125.     // Offset within a box to the upper left of the writing area.
  126.     UINT    cxOffset;
  127.     UINT    cyOffset;
  128.  
  129.     // Width and height of writing area.
  130.     UINT    cxWriting;
  131.     UINT    cyWriting;
  132.  
  133.     // Baseline and midline information for western alphabets.  They are measured from
  134.     // the top of the writing area.  These fields are not used and must be set to zero
  135.     // for the Far East languages (Japanese, Chinese, and Korean).  They must be set to
  136.     // the correct values for English or any other language based on Latin letters.
  137.     UINT    cyMid;
  138.     UINT    cyBase;
  139.  
  140.     // Writing direction
  141.     UINT    nDir;
  142. } HWXGUIDE, *PHWXGUIDE;
  143.  
  144. // The following are the currently planned handwriting directions.  Note that a given recognizer
  145. // may not support the requested direction, if this is the case, HwxSetGuide will return an error.
  146.  
  147. #define    HWX_HORIZONTAL        0
  148. #define    HWX_BIDIRECTIONAL    1
  149. #define    HWX_VERTICAL        2
  150.  
  151. // Called once to initialize DLL.
  152. // On failure, use GetLastError() to identify the cause of the error.
  153. BOOL    WINAPI HwxConfig();
  154.  
  155. // Called to create an HRC before any ink is collected. You can pass in NULL
  156. // for the parameter, but if you pass in an old HRC, it copies the old settings (such
  157. // as alphabet, guide structure, previous context, etc.)
  158. // JRB: FIXME: Make above description of what's copied clearer.
  159. // On failure, use GetLastError() to identify the cause of the error.
  160. HRC        WINAPI HwxCreate(HRC);
  161.  
  162. // Called to destroy an HRC after recognition is complete.
  163. // On failure, use GetLastError() to identify the cause of the error.
  164. BOOL    WINAPI HwxDestroy(HRC);
  165.  
  166. // Tells the HRC where the boxes on the screen are.
  167. // On failure, use GetLastError() to identify the cause of the error.
  168. BOOL    WINAPI HwxSetGuide(HRC, HWXGUIDE *);
  169.  
  170. // Limits the set of characters the recognizer can return.  (See ALC values above.)
  171. // On failure, use GetLastError() to identify the cause of the error.
  172. BOOL    WINAPI HwxALCValid(HRC, ALC);
  173.  
  174. // Reorders the characters the recognizer returns so that selected characters
  175. // appear at the top of the list.  (See ALC values above.)
  176. // On failure, use GetLastError() to identify the cause of the error.
  177. BOOL    WINAPI HwxALCPriority(HRC, ALC);
  178.  
  179. // Sets parameter for partial recognition.
  180. // On failure, use GetLastError() to identify the cause of the error.
  181. BOOL    WINAPI HwxSetPartial(HRC, UINT);
  182.  
  183. #define    HWX_PARTIAL_ALL        0
  184. #define    HWX_PARTIAL_ORDER    1
  185. #define    HWX_PARTIAL_FREE    2
  186.  
  187. // Sets abort address.
  188. // On failure, use GetLastError() to identify the cause of the error.
  189. BOOL    WINAPI HwxSetAbort(HRC, UINT *);
  190.  
  191. // Adds ink to the HRC.
  192. // Takes the HRC, the array of points, the count of points, and 
  193. // the time stamp of the first mouse event in the stroke.  The
  194. // time stamp should be taken directly from the MSG structure
  195. // for the mouse down event.  The points should be scaled to
  196. // match the guide structure.
  197. // On failure, use GetLastError() to identify the cause of the error.
  198. BOOL    WINAPI HwxInput(HRC, POINT *, UINT, DWORD);
  199.  
  200. // Called after last ink is added.  You cannot add anymore ink
  201. // to the HRC after this has been called.
  202. // On failure, use GetLastError() to identify the cause of the error.
  203. BOOL    WINAPI HwxEndInput(HRC);
  204.  
  205. // Recognizes as much ink as it can.
  206. // On failure, use GetLastError() to identify the cause of the error.
  207. BOOL    WINAPI HwxProcess(HRC);
  208.  
  209. // Retrieves the results from an HRC. This may be called repeatedly. This allows you
  210. // to get results for several characters at a time. The return value is the number of
  211. // characters actually returned.  The results for those characters are put in the
  212. // rgBoxResults buffer that was passed in.
  213. // Returns -1 on error.
  214. // On failure, use GetLastError() to identify the cause of the error.
  215. INT        WINAPI HwxGetResults(
  216.     HRC            hrc,            // HRC containing results
  217.     UINT        cAlt,            // number of alternates
  218.     UINT        iFirst,            // index of first character to return
  219.     UINT        cBoxRes,        // number of characters to return
  220.     HWXRESULTS    *rgBoxResults    // array of cBoxRes ranked lists
  221. );
  222.  
  223. // Tells the HRC what the previous character was for context purposes.
  224. // On failure, use GetLastError() to identify the cause of the error.
  225. BOOL    WINAPI HwxSetContext(HRC, WCHAR);
  226.  
  227. // Tells you how many results can be retrieved from HwxGetResults.
  228. // Returns -1 on error.
  229. // On failure, use GetLastError() to identify the cause of the error.
  230. INT        WINAPI HwxResultsAvailable(HRC);
  231.  
  232. #ifdef __cplusplus
  233. }
  234. #endif // __cplusplus
  235.  
  236. #endif // #define _INC_RECOG
  237.